package com.redtrusssoftware.truckloaderpro;

import java.util.ArrayList;
import java.util.List;

import com.parse.FindCallback;
import com.parse.Parse;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class TruckController extends Activity {

	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		Parse.initialize(this, "fYPxyNR0IV4bJsKnupZpLJnvurlXfXDjltYSmWRF", "AySq0ABtcNNlNYWCNoKv0GK95XsRil834GOXgucJ"); 
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.setContentView(R.layout.customrowtruck);
        
        TextView txtProduct = (TextView) findViewById(R.id.name);
        
        Intent i = getIntent();
        String test = i.getStringExtra("test");
        
        txtProduct.setText(test);
        
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Truck");
        query.whereEqualTo("event", "Event AAA");
        query.findInBackground(new FindCallback<ParseObject>() {        
		@Override
		public void done(List<ParseObject> objects, ParseException e) {
			ArrayList<Truck> truckList = new ArrayList<Truck>();
			if(e == null){
				for(ParseObject obj : objects){
					Truck truck = new Truck();
					String truckName = obj.getString("name");
					truck.setName(truckName);
					truckList.add(truck);
					Toast.makeText(getApplicationContext(), "bla"+truckName, Toast.LENGTH_SHORT).show();
				}
				
			}else{
    	        Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
			}
		//	ListView list = (ListView)findViewById(R.id.ListView02);            	
        //	list.setAdapter(new CustomAdapterTruck(TruckController.this,trucks));
		//	Toast.makeText(getApplicationContext(), Integer.toString(truckList.size()), Toast.LENGTH_SHORT).show();
		}
        });

}
}